<template>
  <div id="leftMenu">
    <div class="logo">Logo</div>
    <div class="menuCol">
      <el-row class="">
        <el-col :span="12">
          <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            background-color="#2c2f40"
            text-color="#fff"
            active-text-color="#ffd04b">
            <el-submenu index="1">
              <template slot="title">
                <span>游戏管理</span>
              </template>
              <el-menu-item index="1-1" @click="headerMenuClick('gameIndex')">微信游戏</el-menu-item>
              <el-menu-item index="1-2" @click="headerMenuClick('gameAdIndex')">游戏广告</el-menu-item>
              <el-menu-item index="1-3" @click="headerMenuClick('gamePropIndex')">游戏道具</el-menu-item>
            </el-submenu>
            <el-submenu index="2">
              <template slot="title">
                <span>渠道管理</span>
              </template>
              <el-menu-item index="1-1" @click="headerMenuClick('gameChannelIndex')">游戏渠道</el-menu-item>
              <el-menu-item index="1-2">渠道类型</el-menu-item>
            </el-submenu>
          </el-menu>
        </el-col>
      </el-row>
    </div>
    <div class="header">
      <div class="header-user">
        <div class="user" v-popover:popover>
          <img src="@/assets/img/icon_默认头像.svg" alt="">
          {{accountName}}
        </div>
        <el-popover
          ref="popover"
          v-model="userShow"
          placement="bottom"
          width="158"
          trigger="click">
          <div class="box">
            <!--<div @click="edit" v-if="accountName!='admin'">-->
              <!--<img src="@/assets/img/icon_修改密码.svg" alt="">-->
              <!--修改密码-->
            <!--</div>-->
            <div @click="loginout">
              <img src="@/assets/img/icon_退出.svg" alt="" class="last">
              退出登录
            </div>
          </div>
        </el-popover>
      </div>
      <!--<div @click="loginout" class="fr loginout">退出</div>-->
    </div>
    <!--菜单标签导航栏-->
    <div class="tags-con">
      <tags-page-opened :pageTagsList="pageTagsList"></tags-page-opened>
    </div>
  </div>
</template>
<script>
  export default{
    name: 'leftMenu',
    data() {
      return {
        userShow: false,
      }
    },
    computed: {
      accountName(){
        return this.$store.state.accountObj ? this.$store.state.accountObj.accountName : ''
      },
      pageTagsList () {
        return this.$store.state.pageOpenedList; // 打开的页面的页面对象
      },
    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      loginout () {
        sessionStorage.setItem('token', '')
        this.$store.commit('loginOut');
        this.$router.push({name: 'login'});
      },
      headerMenuClick(name) {
        this.$router.push({name: name});
      },
    }
  }
</script>
<style lang="scss">
  .el-menu {
    border-right: solid 0px #e6e6e6;
    list-style: none;
    position: relative;
    margin: 0;
    padding-left: 0;
    background-color: #FFF;
  }
  .el-submenu .el-menu-item {
    height: 50px;
    line-height: 50px;
     padding: 0 4px;
    min-width: 200px;
  }
  .logo{
    background: #20222E;
    color: #fff;
    text-align: center;
    height: 50px;
    line-height: 50px;
    font-size: 20px;
    position: fixed;
    left: 0;
    top:0;
    width: 200px;
  }
  .menuCol{
    box-sizing: border-box;
    /*padding: 20px 0;*/
    position: fixed;
    left: 0;
    top: 50px;
    bottom: 0;
    width: 200px;
    background: #292C38;
  }
  .el-col-12 {
    width: 100%;
  }
  #layout .page{
    margin-left: 200px;
    background: #F5F7FA;
    padding: 12px 30px;
  }
</style>
<style lang="scss">
  .header{
    width: 100%;
    height: 50px;
    background: #fff;
    box-shadow: 0 1px 2px 0 rgba(153,153,153,0.30);
  }
  .sidebar{
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 140px;
    background: #313641;
  }
  .loginout{
    float: right;
    margin-right: 20px;
    line-height: 70px;
    cursor: pointer;
  }
  .header-user {
    position: absolute;
    top: 10px;
    right: 56px;
    cursor: pointer;
    .user {
      img {
        width: 30px;
        height: 30px;
        margin-right: 14px;
      }
    }
  }
  .el-popover {
    width: 158px;
    background: #FFFFFF;
    box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    text-align: left;
    padding: 0;
    margin-top: 0 !important;
    .box {
      > div {
        height: 46.5px;
        line-height: 46.5px;
        font-size: 14px;
        color: rgba(0, 0, 0, 0.65);
        border-bottom: 1px solid #E1E1E1;
        padding-left: 20px;
        cursor: pointer;
        &:last-child {
          border: none;
        }
        img {
          margin-right: 10px;
          &.last {
            position: relative;
            left: -2px;
            margin-right: 6px;
          }
        }
      }
    }
  }
  .tags-con{
    height: 50px;
    margin-left: 200px;
    z-index: -1;
    overflow: hidden;
    background: #FAFAFA;
    box-shadow: 0 1px 3px 0 rgba(0,0,0,.12), 0 0 3px 0 rgba(0,0,0,.04);
  }
</style>
